<?php

/**
 * @link https://github.com/BigKuCha/yii2-ueditor-widget
 * @link http://ueditor.baidu.com/website/index.html
 */

namespace common\widgets;

use Yii;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\helpers\Url;
use yii\web\View;
use kucha\ueditor\UEditor as InputWidget;

class UEditor extends InputWidget {

    public $clientOptions = [
        'toolbars' => [
            [
                'fullscreen', 'source', '|',
                'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'horizontal', 'removeformat', 'formatmatch', '|',
                'fontsize', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', '|',
                'indent', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
                'link', 'unlink', '|',
                'simpleupload', 'insertimage', '|',
                'pasteplain', 'selectall', 'cleardoc',
            ],
        ],
        'wordCount' => false,
        'elementPathEnabled' => false,
        'enableAutoSave' => false,
        'zIndex' => 10000,
    ];

    /**
     * @throws \yii\base\InvalidConfigException
     */
    public function init() {
        $this->_options = [
            'serverUrl' => Url::to(['/attachs/ueditor']),
            'initialFrameHeight' => 400,
            'lang' => (strtolower(Yii::$app->language) == 'en-us') ? 'en' : 'zh-cn',
        ];
        $this->clientOptions = ArrayHelper::merge($this->_options, $this->clientOptions);
        parent::init();
    }

}
